@@ -34,6 +34,7 @@ public interface BookMapper {
    @ResultMap("bookMap")
//根据id查询图书信息
    Book findById(String id);

    @Select({"<script>" +
            "SELECT * FROM book " +
            "where book_status !='3'" +
            @@ -47,27 +48,148 @@ public interface BookMapper {
        //分页查询图书
        Page<Book> searchBooks(Book book);

        //新增图书
        @Insert({"<script>",
                "INSERT INTO book ",
                "<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">",
                "<if test=\"id != null\">",
                "book_id,",
                "</if>",
                "<if test=\"name != null\">",
                "book_name,",
                "</if>",
                "<if test=\"isbn != null\">",
                "book_isbn,",
                "</if>",
                "<if test=\"press != null\">",
                "book_press,",
                "</if>",
                "<if test=\"author != null\">",
                "book_author,",
                "</if>",
                "<if test=\"pagination != null\">",
                "book_pagination,",
                "</if>",
                "<if test=\"price != null\">",
                "book_price,",
                "</if>",
                "<if test=\"uploadTime != null\">",
                "book_uploadtime,",
                "</if>",
                "<if test=\"status != null\">",
                "book_status,",
                "</if>",
                "<if test=\"borrower != null\">",
                "book_borrower,",
                "</if>",
                "<if test=\"borrowTime != null\">",
                "book_borrowtime,",
                "</if>",
                "<if test=\"returnTime != null\">",
                "book_returntime,",
                "</if>",
                "</trim>",
                "VALUES",
                "<trim prefix=\"(\" suffix=\")\" suffixOverrides=\",\">",
                "<if test=\"id != null\">",
                "#{id},",
                "</if>",
                "<if test=\"name != null\">",
                "#{name},",
                "</if>",
                "<if test=\"isbn != null\">",
                "#{isbn},",
                "</if>",
                "<if test=\"press != null\">",
                "#{press},",
                "</if>",
                "<if test=\"author != null\">",
                "#{author},",
                "</if>",
                "<if test=\"pagination != null\">",
                "#{pagination},",
                "</if>",
                "<if test=\"price != null\">",
                "#{price},",
                "</if>",
                "<if test=\"uploadTime != null\">",
                "#{uploadTime},",
                "</if>",
                "<if test=\"status != null\">",
                "#{status},",
                "</if>",
                "<if test=\"borrower != null\">",
                "#{borrower},",
                "</if>",
                "<if test=\"borrowTime != null\">",
                "#{borrowTime},",
                "</if>",
                "<if test=\"returnTime != null\">",
                "#{returnTime},",
                "</if>",
                "</trim>",
                "</script>"})

        //新增图书
        Integer addBook(Book book);

        //编辑图书信息
        @Update({"<script>",
                "UPDATE book ",
                "<trim prefix=\"set\" suffixOverrides=\",\">",
                "<if test=\"name!= null\">",
                "book_name = #{name},",
                "</if>",
                "<if test=\"isbn!= null\">",
                "book_isbn = #{isbn},",
                "</if>",
                "<if test=\"press!= null\">",
                "book_press = #{press},",
                "</if>",
                "<if test=\"author!= null\">",
                "book_author = #{author},",
                "</if>",
                "<if test=\"pagination!= null\">",
                "book_pagination = #{pagination},",
                "</if>",
                "<if test=\"price!= null\">",
                "book_price = #{price},",
                "</if>",
                "<if test=\"uploadTime!= null\">",
                "book_uploadtime = #{uploadTime},",
                "</if>",
                "<if test=\"status!= null\">",
                "book_status = #{status},",
                "</if>",
                "<if test=\"borrower!= null\">",
                "book_borrower = #{borrower},",
                "</if>",
                "<if test=\"borrowTime!= null\">",
                "book_borrowtime = #{borrowTime},",
                "</if>",
                "<if test=\"returnTime!= null\">",
                "book_returntime = #{returnTime},",
                "</if>",
                "</trim>",
                "WHERE book_id = #{id}",
                "</script>"
        })
        //编辑图书信息
        Integer editBook(Book book);


        @Select(
                {"<script>" +
                        "SELECT * FROM book " +
                        "where book_borrower=#{borrower}" +
                        "AND book_status ='1'" +
                        "<if test=\"name != null\"> AND  book_name  like  CONCAT('%',#{name},'%')</if>" +
                        "<if test=\"press != null\"> AND book_press like  CONCAT('%', #{press},'%') </if>" +
                        "<if test=\"author != null\"> AND book_author like  CONCAT('%', #{author},'%')</if>" +
                        "or book_status ='2'" +
                        "<if test=\"name != null\"> AND  book_name  like  CONCAT('%',#{name},'%')</if>" +
                        "<if test=\"press != null\"> AND book_press like  CONCAT('%', #{press},'%') </if>" +
                        "<if test=\"author != null\"> AND book_author like  CONCAT('%', #{author},'%')</if>" +
                        "order by book_borrowtime" +
                        "</script>"})
        @Select({"<script>" +
                "SELECT * FROM book " +
                "where book_borrower=#{borrower}" +
                "AND book_status ='1'" +
                "<if test=\"name != null\"> AND  book_name  like  CONCAT('%',#{name},'%')</if>" +
                "<if test=\"press != null\"> AND book_press like  CONCAT('%', #{press},'%') </if>" +
                "<if test=\"author != null\"> AND book_author like  CONCAT('%', #{author},'%')</if>" +
                "or book_status ='2'" +
                "<if test=\"name != null\"> AND  book_name  like  CONCAT('%',#{name},'%')</if>" +
                "<if test=\"press != null\"> AND book_press like  CONCAT('%', #{press},'%') </if>" +
                "<if test=\"author != null\"> AND book_author like  CONCAT('%', #{author},'%')</if>" +
                "order by book_borrowtime" +
                "</script>"
        })
        @ResultMap("bookMap")
//查询借阅但未归还的图书和待归还确认的图书
        Page<Book> selectBorrowed(Book book);
        @@ -75,11 +197,11 @@ public interface BookMapper {
            @Select({"<script>" +
                    "SELECT * FROM book " +
                    "where book_borrower=#{borrower}" +
                    "AND book_status in('1','2')" +
                    " AND book_status in('1','2') " +
                    "<if test=\"name != null\"> AND  book_name  like  CONCAT('%',#{name},'%')</if>" +
                    "<if test=\"press != null\"> AND book_press like  CONCAT('%', #{press},'%') </if>" +
                    "<if test=\"author != null\"> AND book_author like  CONCAT('%', #{author},'%')</if>" +
                    "order by book_borrowtime" +
                    " order by book_borrowtime" +
                    "</script>"})
            @ResultMap("bookMap")